require File.dirname(__FILE__) + '/test_helper'

class TestSearch < Test::Unit::TestCase

  VALID_PARAMS = {
    :q => 'gloria',
    :tags => ['madrid', 'barcelona'],
    :as => '/es',
    :bbox => ['23452345', '345325', '23434', '32453245'],
    :tag_op => 'and',
    :lon => '2345',
    :lat => '234234',
    :radius => '3'    
  }

  def test_parse_params_without_arguments
    assert_raise(RuntimeError) { Oos4ruby::Search.parse_params(nil) }
    assert_raise(RuntimeError) { Oos4ruby::Search.parse_params({}) }
  end

  def test_parse_params_with_arguments
    query = Oos4ruby::Search.parse_params(VALID_PARAMS)

    assert query.include?("q=gloria")
    assert query.include?("tag=madrid")
    assert query.include?("tag=barcelona")
    assert query.include?("as=/es")
    assert query.include?("bbox=23452345,345325,23434,32453245")
    assert query.include?("tagOp=and")
    assert query.include?("lon=2345")
    assert query.include?("lat=234234")
    assert query.include?("radius=3")
  end
end
